package test.nettys.nio;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @Author wangshaopeng
 * @Date 2021/7/14
 */
public class NioTest2 {


    public static void main(String[] args) throws IOException {
        FileOutputStream outputStream = new FileOutputStream("test/nettys/test2.txt");
        FileChannel channel = outputStream.getChannel();

        ByteBuffer buffer = ByteBuffer.allocate(100);
        for (byte aByte : "cdsvdsvsvds".getBytes()) {
            buffer.put(aByte);
        }
        buffer.flip();

        channel.write(buffer);


        outputStream.close();

    }
}
